home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Commands / Fireworks HTML.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  4.1 KB  |  166 lines

  1. // Copyright 1999 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS  *****************
  4.  
  5. var helpDoc = MM.HELP_objFireworksHTML;
  6.  
  7. var OBJECT_TAG = '';
  8. var CMD_PATH = dreamweaver.getConfigurationPath() + "/Commands/Fireworks HTML.htm";
  9.  
  10. /*
  11. var DOC_NAME = '';
  12. var SITE_NAME = '';
  13. var SAVED = false;
  14. */
  15.  
  16.  
  17. //******************* API **********************
  18.  
  19. function getObjectTag() {
  20.   return OBJECT_TAG;
  21. }
  22.  
  23. function commandButtons()
  24. {
  25.    return new Array( BTN_OK,     "setObjectTag()",
  26.                      BTN_Cancel, "cancelObjectTag()",
  27.                      BTN_Help,   "displayHelp()");
  28. }
  29.  
  30.  
  31. function setObjectTag() {
  32.   var result, validFWFile=false;
  33.   var fwFile, fwHTML, fwURL, fwSource, fwDOM;
  34.   var docURL, siteURL, parentFile, docRootURL, siteRootURL;
  35.  
  36.   fwHTML = document.theForm.htmlFile.value;
  37.   if (fwHTML) {
  38.     fwURL = MMNotes.filePathToLocalURL(fwHTML);
  39.     fwFile = new File(fwURL);
  40.   }
  41.  
  42.   if (!fwHTML) {
  43.     alert(MSG_selectFWFile);
  44.   } else if (!fwFile.exists() || !fwFile.isFile()) {
  45.     alert(printf(MSG_selectValidFile,fwHTML));
  46.   } else {
  47.     fwSource = fwFile.getContents();
  48.     if (!isFireworksHTML(fwSource))
  49.       alert(MSG_notFWFile);
  50.     else if (!isDWStyle(fwSource))
  51.       alert(MSG_notExportedForDW);
  52.     else if (!usesDWBehaviors(fwSource))
  53.       alert(MSG_behNotSupported);
  54.     else
  55.       validFWFile = true;
  56.   }
  57.  
  58.   if (validFWFile) {
  59.     fwDOM = dreamweaver.getDocumentDOM(fwURL);
  60.     docURL = dreamweaver.getDocumentPath("document");
  61.     siteURL = dreamweaver.getSiteRoot();
  62.  
  63.     docRootURL = '';
  64.     siteRootURL = '';
  65.     if (docURL) {
  66.       parentFile = new File(docURL);
  67.       docRootURL = parentFile.getAbsoluteParent() + File.separator;
  68. /*
  69.       if (document.theForm.urlRelTo.selectedIndex == 1) {
  70.         parentFile = new File(siteURL);
  71.         siteRootURL = parentFile.getAbsolutePath();
  72.       }
  73. */
  74.     }
  75.  
  76.     OBJECT_TAG = insertFireworksHTML(fwDOM, fwURL, docRootURL, siteRootURL);
  77.  
  78.     dreamweaver.releaseDocument(fwDOM);
  79.     window.close();
  80.  
  81.     if (document.theForm.delHtml.checked) {
  82.       fwFile = new File(fwURL);
  83.       result = fwFile.remove();
  84.       if (!result)
  85.         alert(printf(MSG_cantRemoveHTML, fwURL));
  86.   } }
  87.  
  88.   // save current settings to the metafile
  89.   handle = MMNotes.open(CMD_PATH, true);
  90.   if (handle != 0) {
  91.     MMNotes.set(handle, "DeleteOption", document.theForm.delHtml.checked.toString());
  92. /*
  93.     MMNotes.set(handle, "URLOption", document.theForm.urlRelTo.selectedIndex.toString());
  94. */
  95.     MMNotes.close(handle);
  96.   }
  97.  
  98. }
  99.  
  100. function cancelObjectTag() {
  101.   OBJECT_TAG = '';
  102.   window.close();
  103. }
  104.  
  105. //***************** LOCAL FUNCTIONS  ******************
  106.  
  107. function initializeUI() {
  108.   var handle, filePath, deleteHTML, urlRel;
  109.   OBJECT_TAG = '';
  110.  
  111.   document.theForm.delHtml.checked = false;
  112.  
  113.   // load any previously saved settings from the metafile
  114.   handle = MMNotes.open(CMD_PATH);
  115.   if (handle != 0) {
  116.     deleteHTML = eval(MMNotes.get(handle, "DeleteOption"));
  117.     if (deleteHTML) document.theForm.delHtml.checked = true;
  118. /*
  119.     urlRel = eval(MMNotes.get(handle, "URLOption"));
  120.     if (urlRel) document.theForm.urlRelTo.selectedIndex = urlRel;
  121. */
  122.     MMNotes.close(handle);
  123.   }
  124.  
  125. /*
  126.   DOC_NAME = dreamweaver.getDocumentDOM('document').getWindowTitle();
  127.   SITE_NAME = site.getCurrentSite();
  128.   SAVED = (dreamweaver.getDocumentPath('document').length != 0);
  129.  
  130.   displayURLSelection();
  131. */
  132.  
  133.   // set the selection and focus
  134.   document.theForm.htmlFile.select();
  135.   document.theForm.htmlFile.focus();
  136. }
  137.  
  138.  
  139. function updateUI(itemName) {
  140.   var result = '';
  141.   if (itemName == "browseHtml") {
  142.     result = dreamweaver.browseForFileURL("open", LABEL_selectFW, false);
  143.     if (result) document.theForm.htmlFile.value = result;
  144.   } else if (itemName == "urlRelTo") {
  145. /*
  146.     displayURLSelection();
  147. */
  148.   }
  149. }
  150.  
  151. /*
  152. function displayURLSelection() {
  153.   if (document.theForm.urlRelTo.selectedIndex == 0) {
  154.     if (SAVED)
  155.       document.theForm.linkRelName.innerHTML = DOC_NAME;
  156.     else
  157.       document.theForm.linkRelName.innerHTML = LABEL_noSavedDoc;
  158.   } else if (document.theForm.urlRelTo.selectedIndex == 1) {
  159.     if (SITE_NAME)
  160.       document.theForm.linkRelName.innerHTML = SITE_NAME;
  161.     else
  162.       document.theForm.linkRelName.innerHTML = LABEL_noDefinedSite;
  163.   }
  164. }
  165. */
  166.